package com.xbn.netty.simpleHttp;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author XBN
 * @date 2020/10/20 17:03
 * @email 78742541@qq.com
 */
/*
* 客户端管道初始化
* */
public class HttpTestServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //给管道假如处理器
        //得到管道
        ChannelPipeline pipeline = socketChannel.pipeline();
        //加入一个netty提供的httpServerCodec  codec=>[coder-decoder] 指的是编码和解码
        //这是netty提供的一个处理http的编码解码器，
        pipeline.addLast("XbnHttpServerCodec",new HttpServerCodec());
        //增加一个自定义的处理器
        pipeline.addLast("XbnHttpServerHandler",new HttpTestServerHandler());
    }
}
